package com.manli.api.base.aop;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器
 * @author Shensg
 *
 * 2020年3月25日
 */
@Configuration
public class WebAppConfig implements WebMvcConfigurer{    
    
	@Bean
    public AuthenticationInterceptor getAuthenticationInterceptor(){
        return new AuthenticationInterceptor();
    }
    /**
     * WebMvcConfigurerAdapter 在Spring5.0已被废弃
     * 或则extends WebMvcConfigurationSupport  
     */
    /** 
     * 配置拦截器 
     * @author lance 
     * @param registry 
     */  
    @Override
    public void addInterceptors(InterceptorRegistry registry) {  
    	/**
    	 * 拦截所有点do
    	 */
        registry.addInterceptor(getAuthenticationInterceptor()).
        	addPathPatterns("/**")
        	//排除login
        	.excludePathPatterns("/login/*")
        	.excludePathPatterns("/login")
        	//排除html
        	.excludePathPatterns("/**/*.html")
        	.excludePathPatterns("/**/*.js")
        	.excludePathPatterns("/**/*.css")
        	.excludePathPatterns("/js/**")
        	.excludePathPatterns("/css/**")
        	.excludePathPatterns("/font/**")
        	.excludePathPatterns("/img/**")
        	.excludePathPatterns("/vid/**")
        	.excludePathPatterns("*.png")
        	//排除txt 微信校验
        	.excludePathPatterns("/*.txt")
        	//排除swagger
        	.excludePathPatterns("/swagger-resources")
        	.excludePathPatterns("/v2/api-docs")
        	//排除druid 他有账号密码了
        	.excludePathPatterns("/druid/*"); 
    }  
}  